Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AOS-EMU2: Add contact,relay,outlet discovery; update yaml,snmprec,json #8317

Merged
merged 7 commits into from Mar 17, 2018

Conversation

axemann
Copy link
Contributor

@axemann axemann commented Mar 1, 2018

DO NOT DELETE THIS TEXT

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926

@axemann
Copy link
Contributor Author

axemann commented Mar 2, 2018

Hey guys, not sure what to do about the snmprec error. The same pre-commit parameters pass on my test box: https://p.libren.ms/view/a921acc6.

array($state_index_id,'Normal',0,1,0) ,
array($state_index_id,'Alert',0,2,1)
);
foreach ($states as $value) {
Copy link
Member

@murrant murrant Mar 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is using old style state definitions.
Please see the documentation for an updated code style (or use yaml).
https://docs.librenms.org/Developing/Sensor-State-Support/

$index = $contact['emsInputContactStatusInputContactIndex'];
$oid = '.1.3.6.1.4.1.318.1.1.10.3.14.1.1.3.' . $index;
$descr = $contact['emsInputContactStatusInputContactName'];
$currentstate = $contact['emsInputContactStatusInputContactState'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns a string when you use the mib, so you need to convert the string to a numeric value.

$state_index_id = create_state_index($state_name_nc);
if ($state_index_id !== null) {
$states = array(
array($state_index_id,'Normal',0,1,0) ,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the time it is better if you used the names returned by snmp instead of Normal and Alert. So: contactOpenEMS and contactClosedEMS. Or at least change the description to Open and Closed ( you can keep the inverted generic values so it correctly shows up as green or red)

mib_dir:
- apc
discovery:
- sysObjectID:
- .1.3.6.1.4.1.318.1.3.8.2
- .1.3.6.1.4.1.318.1.3.8.3
discovery_modules:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is kind of pointless and misleading to disable all these modules. Most don't do anything on your device.

@murrant
Copy link
Member

murrant commented Mar 9, 2018

While troubleshooting, I converted the states to the new format, here you go:

        $state_name_nc = 'emsInputContactNormalState_NC';
        $states = array(
            array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Open'),
            array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Alert'),
        );
        create_state_index($state_name_nc, $states);
        $state_name_no = 'emsInputContactNormalState_NO';
        $states = array(
            array('value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'Alert'),
            array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'),
        );
        create_state_index($state_name_no, $states);
        $state_name_nc = 'emsOutputRelayNormalState_NC';
        $states = array(
            array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'),
            array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Alert'),
        );
        create_state_index($state_name_nc, $states);
       $state_name_no = 'emsOutputRelayNormalState_NO';
        $states = array(
            array('value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'Alert'),
            array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'),
        );
        create_state_index($state_name_no, $states);
        $state_name_on = 'emsOutletNormalState_ON';
        $states = array(
            array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'On'),
            array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Off'),
        );
        create_state_index($state_name_on, $states);
        $state_name_off = 'emsOutletNormalState_OFF';
        $states = array(
            array('value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'On'),
            array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Off'),
        );
        create_state_index($state_name_off, $states);

Remember my suggestion to change the descriptions from Alert/Normal to the snmp name or Open/Closed.

@axemann
Copy link
Contributor Author

axemann commented Mar 9, 2018

Thanks @murrant. I'll work on fixing this up tonight/tomorrow and incorporating your converted states above. Sorry for all the trouble, still learning over here. :-)

@murrant
Copy link
Member

murrant commented Mar 10, 2018

No worries. I'd like to convert the existing ones so people have good source code to look at, but haven't had time and it's working mostly 😀

@murrant
Copy link
Member

murrant commented Mar 10, 2018

Let us know if you have any questions.

@murrant murrant changed the title Add contact,relay,outlet discovery; update yaml,snmprec,json AOS-EMU2: Add contact,relay,outlet discovery; update yaml,snmprec,json Mar 17, 2018
@murrant murrant added the Device 🖥️ New or added device support label Mar 17, 2018
@murrant
Copy link
Member

murrant commented Mar 17, 2018

@laf another one trying to insert strings into a numeric field in the database.

@scrutinizer-notifier
Copy link

The inspection completed: No new issues

@murrant murrant merged commit d20d6fc into librenms:master Mar 17, 2018
@lock
Copy link

lock bot commented May 16, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed.

@lock lock bot locked as resolved and limited conversation to collaborators May 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Device 🖥️ New or added device support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants